package com.fox.imagedb.listener;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPopupMenu;

public class PhylTreePopupListener extends MouseAdapter {

    private JPopupMenu popup;

    public PhylTreePopupListener(JPopupMenu popup) {
	super();
	this.popup = popup;
    }

    public void mousePressed(MouseEvent e) {
	maybeShowPopup(e);
    }

    public void mouseReleased(MouseEvent e) {
	maybeShowPopup(e);
    }

    private void maybeShowPopup(MouseEvent e) {
	if (e.isPopupTrigger()) {
	    popup.show(e.getComponent(), e.getX(), e.getY());
	}
    }

}
